﻿namespace XmlConsoleApp
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Console.WriteLine(Constants.PROBE_MESSAGE.Length);
            var context = Constants.PROBE_MESSAGE.ReplacePattern(@"(<|/)[a-z\-]+:", "$1");
            var context1 = Constants.PROBE_MESSAGE.ReplacePattern(@"(<|/)[a-z0-9\-]+:", "$1");
            Console.WriteLine(context.Length);
            /*
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(Constants.PROBE_MESSAGE);

            // 将 XML 转换为 JSON
            string json = JsonConvert.SerializeXmlNode(xmlDoc);
            Console.WriteLine(json);
            */

            /*
            var xmlElements = Constants.PROBE_MESSAGE.ToXElement(Encoding.UTF8);
            var nodes = xmlElements.Elements();
            var node = nodes.First();
            var subNodes = node.Elements();
            var subNode = subNodes.First();
            foreach (var item in subNode.Elements())
            {
                Console.WriteLine(item.Name);
            }
            */

            /*
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(Constants.PROBE_MESSAGE);

            // 获取所有 Preset 元素
            XmlNodeList presetNodes = xmlDoc.SelectNodes("//tptz:Preset");
            List<Preset> presets = new List<Preset>();

            // 遍历每个 Preset 元素
            foreach (XmlNode presetNode in presetNodes)
            {
                Preset preset = new Preset();
                preset.Id = presetNode.Attributes["token"].Value;
                preset.Name = presetNode["tt:Name"].InnerText;

                // 获取 PTZPosition 元素
                XmlNode ptzPositionNode = presetNode["tt:PTZPosition"];

                // 获取 PanTilt 元素
                XmlNode panTiltNode = ptzPositionNode["tt:PanTilt"];
                preset.Position.Pan = panTiltNode.Attributes["x"].Value;
                preset.Position.Tilt = panTiltNode.Attributes["y"].Value;

                // 获取 Zoom 元素
                XmlNode zoomNode = ptzPositionNode["tt:Zoom"];
                preset.Position.Zoom = zoomNode.Attributes["x"].Value;

                presets.Add(preset);
            }
            */
        }

        public class Preset
        {
            public string Id { get; set; }
            public string Name { get; set; }
            public Position Position { get; set; } = new Position();
        }

        public class Position
        {
            public string Pan { get; set; }
            public string Tilt { get; set; }
            public string Zoom { get; set; }
        }
    }
}
